package Algorithms;

import java.util.ArrayList;

public class BS {

	public static int num = 10;
	public static ArrayList<Integer> list = new ArrayList<Integer> (num);
	
	public static int bs(int x){
		int l = list.get(0);
		int i = num - 1;
		int r = list.get(i);
		while(x != list.get(i)){
			i = (l+r)/2;
			if(x < list.get(i))
				 r = i;
			if(x > list.get(i))
				l = i;
		}
		return i;
		
	}
	public static void main(String[] args) {
		for(int i = 0; i < num; i++){
			list.add(i+1);
		}
		int x = 5;
		int i = bs(x);
		System.out.println(i);
		

	}

}
